package com.tidc.seaserverweb.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.tidc.seaservermodel.aspect.WebLog;
import com.tidc.seaservermodel.entity.*;
import com.tidc.seaserverservice.service.RabbitService;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.sql.SQLException;


@RestController
@RequestMapping("/rabbit")
@Order(99)
//TODO 这里增加接口需要去过滤器里增加配置
public class RabbitController {
    @Resource
    private RabbitService rabbitService;
    @PostMapping("/add/experience")
    @WebLog
    public Fres<Integer> seaAddExperience(@RequestBody UserTask userTask) throws SQLException {
        return rabbitService.seaAddExperience(userTask);
    }
    @PostMapping("/punishment/experience")
    @WebLog
    public Fres<Integer> punishmentExperience(@RequestBody UserTask userTask) throws SQLException {
        return rabbitService.punishmentExperience(userTask);
    }
    @PostMapping("/send/email")
    @WebLog
    public Fres<Integer> seaAddEmail(@RequestBody Email email) throws SQLException {
        return rabbitService.seaAddEmail(email);
    }
    @PostMapping("/task/check/timeout")
    @WebLog
    public Fres<Integer> seaTaskCheckTimeout(@RequestBody UserTask userTask) throws JsonProcessingException {
        return rabbitService.seaTaskCheckTimeout(userTask);
    }

    @WebLog
    @PostMapping("/check/commitment/out")
    public Fres<Integer> seaCheckCommitmentOut(@RequestBody Commitment commitment){
        return rabbitService.seaCheckCommitmentOut(commitment);
    }

    @WebLog
    @PostMapping("/clear/rabbit")
    public Fres<Integer> clearRabbit(@RequestBody RabbitMessageLog rabbitMessageLog){
        return rabbitService.clearRabbit(rabbitMessageLog);
    }
}
